<template>
  <div class="operation-monitoring">
    <div class="content-title">
      <div class="title-left">
        <img
          class="title-left-img"
          src="@/assets/img/water/title-icon.png"
          alt=""
        />
        <span class="title-left-span">全天总排水量</span>
      </div>
      <div class="title-right">
        <span class="title-right-num">3733</span><span class="company">m³</span>
      </div>
    </div>
    <div class="content-list">
      <div v-for="(item, index) in showLists" :key="index" class="content-item">
        <div class="content-item-title">
          <div class="content-box">
            <div class="center-item">
              <div>
                <img v-if="item.runStatus === '运行' " src="@/assets/img/water/success.png">
                <img v-if="item.runStatus === '故障' " src="@/assets/img/water/fault.png">
                <img v-if="item.runStatus === '停止' " src="@/assets/img/water/stop.png">
                <span>{{ item.pumpName }}</span>
              </div>
              <span class="status" :style="{color:color(item.runStatus).color,'background-color':color(item.runStatus).bgcolor}">
                {{item.runStatus}}
              </span>
            </div>
          </div>
          <div class="center-box">
            <div class="center-item">
              <img class="img" v-if="item.valveList[0].valveStatus === '完全打开' " src="@/assets/img/water/open.png">
              <img class="img" v-if="item.valveList[0].valveStatus === '完全关闭' " src="@/assets/img/water/close.png">
              <img class="img" v-if="!['完全打开','完全关闭','故障'].includes(item.valveList[0].valveStatus)" src="@/assets/img/water/other.png">
              <div v-if="item.valveList[0].valveStatus === '故障'">
                <el-tooltip class="item" effect="dark" placement="bottom-start">
                  <div slot="content" style="color: #EF303B" v-if="item.valveList[0].valveErrorMsg.length > 0">
                    <span v-for="(v, vi) in item.valveList[0].valveErrorMsg" :key="vi">{{ v }}<br></span>
                  </div>
                  <div slot="content" style="color: #EF303B" v-else>
                    <span>暂无故障原因</span>
                  </div>
                  <div>
                    <svg class="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="16" height="16">
                      <g>
                      <path d="M72.522 369.037h878.957v248.819H72.522z" p-id="9036" fill = '#EF303B'/><path d="M785.597 316.821h165.882v353.252H785.597zM72.522 316.821h165.88v353.252H72.522zM643.383 914.09L285.878 556.586 416.39 426.073l357.506 357.505zM362.831 306.749h298.338v62.289H362.831z" p-id="9037" fill = '#EF303B'/><path d="M462 263.315h100v50H462zM162 163.315h700v100H162z" p-id="9038" fill = '#EF303B'/>
                      </g>
                    </svg>
                  </div>
                </el-tooltip>
              </div>
              <span class="msg-text">阀门开度</span>
              <span class="it-percentage">{{ item.valveList[0].valveOpening }}%</span>
            </div>
          </div>
        </div>
          <div class="inner-box">
            <div class="item-left">
              <div class="title-box">
                <div class="title-info">
                  <div class="">流量</div>
                  <div>
                    <span class="num-text">{{ item.sbScFy }}</span>
                    <span class="unit-text">m³/h</span>
                  </div>
                </div>
                <div class="title-info">
                  <div class="">排水量</div>
                    <div>
                      <span class="num-text">{{ item.sbScFy }}</span>
                      <span class="unit-text">m³</span>
                    </div>
                  </div>
                </div>
              <div class="item-content">
                <div class="left-box">
                  <div class="box">
                    <div class="box-info">
                      <div>正压</div>
                      <div>
                        <span class="num-text">{{ item.sbScFy }}</span>
                        <span class="unit-text">MPa</span>
                      </div>
                    </div>
                    <div class="box-info">
                      <div>负压</div>
                      <div>
                        <span class="num-text">{{ item.sbScZy }}</span>
                        <span class="unit-text">MPa</span>
                      </div>
                    </div>
                  </div>

                  <div class="box">
                    <div class="box-info">
                      <div>前轴温度</div>
                      <div>
                        <span class="num-text">{{ item.sbScBqzwd }}</span>
                        <span class="unit-text">℃</span>
                      </div>
                    </div>
                    <div class="box-info">
                      <div>后轴温度</div>
                      <div>
                        <span class="num-text">{{ item.sbScBzhwd }}</span>
                        <span class="unit-text">℃</span>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="item-right">
              <div>{{ item.level.levelName }}</div>
              <div>
                <span class="level-text">{{ item.level.currentLevel }}</span>
                <span class="unit-text">m</span>
              </div>
              <div class="progress-wrap">
                <div
                  class="progress"
                  :style="{height: (item.level.currentLevel / item.level.limitLevel) * 100 + '%',}"
                  :class="{
                    'red': item.level.currentLevel > item.level.dangerLevel,
                    'white': item.level.currentLevel < item.level.lowLevel,
                    'cyan': item.level.currentLevel > item.level.lowLevel && item.level.currentLevel < item.level.highLevel,
                    'orange': item.level.currentLevel > item.level.highLevel && item.level.currentLevel < item.level.dangerLevel,
                  }"
                />
                <div
                  class="high"
                  :style="{height: (item.level.highLevel / item.level.limitLevel) * 100 + '%',}"
                />
                <div
                  class="low"
                  :style="{height: (item.lowLevel / item.limitLevel) * 100 + '%',}"
                />
              </div>
            </div>
          </div>
      </div>
    </div>
  </div>
</template>

<script>
import { monitorInfo } from '../common/titles';
export default {
  data() {
    return {
      lists: []
    };
  },

  components: {},

  computed: {
    routeId() {
      return this.$route.params.id;
    },
    showLists() {
      const data = this.lists;
      return data;
    },
    color() {
      return function(status) {
        const info = {};
        switch (status) {
          case '运行':
            info.color = '#57FFAA';
            info.bgcolor = '#19504e';
            break;
          case '故障':
            info.color = '#ef303b';
            info.bgcolor = '#3f1e32';
            break;
          case '停止':
            info.color = '#ADADAD';
            info.bgcolor = '#303d50';
            break;
        }
        return info;
      };
    }
  },

  mounted() {
    this.lists = monitorInfo[this.routeId];
  },

  methods: {}
};
</script>
<style scoped lang="scss">
.operation-monitoring {
  .company{
    color: #8D8D8D;
    font-size: .75rem;
  }
  .content-title {
    width: 20.625rem;
    height: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.625rem;
    .title-left {
      .title-left-img {
        width: 1.25rem;
        height: 1.25rem;
        margin-right: 0.625rem;
        vertical-align: middle;
      }
      .title-left-span {
        font-size: 0.875rem;
        color: #f8f8f8;
        vertical-align: middle;
      }
    }
    .title-right-num {
      color: #00fdff;
      font-size: 1rem;
      margin-right: 0.3125rem;
    }
  }
  .content-list{
    .content-item{
      font-size: $commonContentText;
      color: $light3Grey;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-bottom: .625rem;
      .inner-box{
        display: flex;
        justify-content: space-between;
        .item-left{
          flex: 1;
          .item-content{
            .left-box{
              display: flex;
              justify-content: space-between;
              .box{
                display: flex;
                flex-direction: column;
                justify-content: space-evenly;
                width: 8.375rem;
                box-sizing: border-box;
                height: 5.625rem;
                border-radius: 0.25rem;
                background: $itemBg;
                padding: 0 0.3125rem;
                .box-info{
                  color: $light3Grey;
                  font-size: $commonContentText;
                  display: flex;
                  justify-content: space-between;
                  .num-text{
                    font-size: $smallHeadingsText;
                    color: $light3Grey;
                  }
                }
              }
            }
          }
        }
        .item-right{
          width: 3.25rem;
          height: 8.6875rem;
          margin-left: 0.375rem;
          border-radius: 0.25rem;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          padding: .3125rem 0;
          box-sizing: border-box;
          background: $itemBg;
          .level-text{
            font-size: $smallHeadingsText;
            height: 1.25rem;
            line-height: 1.5625rem;
          }
          .progress-wrap{
            margin-top: 0.625rem;
            width: 1rem;
            height: 5.3125rem;
            border: 0.0625rem solid rgba(173, 173, 173, 0.5);
            background-color: rgba(255, 255, 255, 0.15);
            position: relative;
            div{
              position: absolute;
              bottom: 0;
              width: 100%;
            }
            .progress{
              height: 80%;
              &.red{
                background-color: $red
              }
              &.white{
                background-color: $white
              }
              &.cyan{
                background-color: $cyan
              }
              &.orange{
                background-color: $orange
              }
            }
            .high{
              height: 90%;
              border-top: 0.0625rem dashed $red
            }
            .low{
              height: 30%;
              border-top: 0.0625rem dashed $red
            }
          }
        }
      }
      .content-item-title{
        display: flex;
        color: $white;
        font-size: $smallHeadingsText;
        height: 1rem;
        line-height: 1rem;
        margin-bottom: .9375rem;
        .content-box{
          vertical-align: middle;
          width: 8.375rem;
          .center-item{
            display: flex;
            align-items: center;
            justify-content: space-between;
          }
          .status{
            height: 1rem;
            font-size: .75rem;
            text-align: center;
            padding: 0 .3125rem;
            display: inline-block;
          }
          img{
            width: 1rem;
            height: 1rem;
            margin-right: 0.625rem;
          }
        }
        .center-box{
          flex:1;
          width: 100%;
          .center-item{
            display: flex;
            align-items: center;
            justify-content: flex-end;
            .img{
              width: 1rem;
              height: 1rem;
              margin-right: .625rem;
              vertical-align: middle;
            }
            .it-name{
              color: $light2Grey;
              width: 2.625rem;
              margin-right: 0.5rem;
              &.alarm-red{
                color: $red;
              }
            }
            .msg-text{
              color: $lightGrey;
              margin-right: .625rem;
              vertical-align: middle;
            }
            .it-percentage{
              color: $blue;
              vertical-align: middle;
            }
          }
        }
      }
      .title-box{
        width: 100%;
        height: 2.75rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: .3125rem;
        .title-info{
          width: 8.375rem;
          height: 100%;
          color: $light3Grey;
          font-size: .875rem;
          display: flex;
          justify-content: space-between;
          align-items: center;
          background-color: #1E2E45;
          border-radius: 0.25rem;
          padding: 0 .625rem;
          box-sizing: border-box;
          .num-text{
            font-size: 1rem;
            color: $light3Grey;
          }
        }
      }
    }
    .content-item:last-child{
      margin-bottom: 0;
    }
  }
}
</style>
